<template lang="html">
    <div class="charge-list">
        <myHeader>
            <div class="add-icon">
                <i class="iconfont icon-add" @click="addEventType"></i>
            </div>
        </myHeader>
        <div class="list-container">
            <div class="item" v-for="(item,index) in list">
                <div class="left">
                    <img :src="imagePrev + '/' + item.picture" @click="showImageView(imagePrev + '/' + item.picture)" alt="">
                </div>
                <div class="right">
                    <div class="top">
                        <span>{{item.storeName}}</span>
                    </div>
                    <div class="bottom">
                        <div class="bottom-left">
                            <span>￥{{item.allPrice}}</span>
                        </div>
                        <div class="bottom-right">
                            <span>2015-12-12 11:11:11</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import ImagePreview from 'vant/lib/image-preview'
export default {
    data(){
        return {
            list: [],
            imagePrev: process.env.BASE_URL
        }
    },
    created(){
        this.getList()
    },
    methods: {
        getList(){
            this.$api.post('/charge/list').then(res => {
                this.list = res.list
            })
        },
        showImageView(src){
            ImagePreview([
                src
            ]);
        },
        addEventType(){
            this.$router.push({
                name: 'chargeAdd'
            })
        }
    }
}
</script>

<style lang="scss" scoped>
    .charge-list{
        background-color: #f5f5f5;
        .add-icon{
            font-size: .16rem;
            text-align: right;
            padding: 0 .1rem;
        }
        .list-container{
            .item{
                display: flex;
                height: 1rem;
                background: #fff;
                margin: .01rem 0;
                padding: .05rem;
                .left{
                    margin-right: .05rem;
                    height: 100%;
                    width: 1.2rem;
                    img{
                        object-fit: cover;
                        height: 100%;
                        width: 100%;
                    }
                }
                .right{
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    font-size: .15rem;
                    .bottom{
                        display: flex;
                        justify-content: space-between;
                        color: #8c8c8c;
                        font-size: .12rem;
                    }
                }
            }
        }
    }
</style>
